import java.net.*;
import java.io.*;

/** LocalTalk2.java
   See command in ServerTalk2.java
*/

public class LocalTalk2 {

    public static void main(String args[] ) {
     try {
	Socket sk = new Socket("sleipnir.cs.csubak.edu", 8902);
	ObjectOutputStream out = new ObjectOutputStream(sk.getOutputStream());
	ObjectInputStream in = new ObjectInputStream(sk.getInputStream());

	String message;
	int mnum = 1;
	int len;
	while ( true ) {
		message = (String) in.readObject();
		System.out.println("client: " + message);

		message = "CLIENT MESSAGE " + mnum++;
		out.writeObject(message);
		out.flush();

		Thread.sleep((int) ( Math.random() * 2000) + 500 );
	}
     } catch ( Exception e ) { e.printStackTrace(); }
   }
}
